# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-gen
_pkgname=gen
pkgver=1.1
pkgrel=0
pkgdesc="Simple, efficient iterators for OCaml"
url="https://github.com/c-cube/gen/"
arch="all !riscv64"  # limited by ocaml aport
license="BSD-2-Clause"
depends="ocaml-runtime ocaml-seq"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-seq-dev"
makedepends="$depends_dev dune dune-configurator ocaml"
checkdepends="ocaml-ounit-dev ocaml-qcheck-dev ocaml-qtest-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/c-cube/gen/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
71a4b5c3666a7c11935398a78feea7383f61d2c549dfb96e324d40783ffa87b5ec492c5ec468803aabfb9b48e7d0ebaa30b24d2b974540afc7cca5feea3121c1  ocaml-gen-1.1.tar.gz
"
